package org.example.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.Likes;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;
import java.util.Set;

/**
* @author Xiri
* @description 针对表【likes】的数据库操作Mapper
* @createDate 2025-07-17 17:55:48
* @Entity org.example.pojo.Likes
*/
public interface LikesMapper extends BaseMapper<Likes> {

//	@Select("""
// 		select username from users where id in<foreach collection="ids" item="id1" open="(" separator="," close=")">
//                                             #{id1}
//                                           </foreach> 
//                                           ORDER BY FIELD(id,<foreach collection="ids" item="id2" separator=",">
//                                             #{id2}
//                                           </foreach>)
//	""")
//	public List<String> likedTop5(@Param("ids") List ids);

//	@Select("""
//    SELECT username FROM users 
//    WHERE id IN 
//    <foreach collection="ids" item="item" open="(" separator="," close=")">
//        #{item}
//    </foreach> 
//    ORDER BY FIELD(id,
//    <foreach collection="ids" item="item" separator=",">
//        #{item}
//    </foreach>)
//""")
//	public List<String> likedTop5(@Param("ids") List ids);

	@Select({"""
			<script>
			SELECT username FROM users
			WHERE id IN
			<foreach collection='ids' item='item' open='(' separator=',' close=')'>
			   #{item}
			</foreach>
			ORDER BY FIELD(id,
			<foreach collection='ids' item='item' separator=','>
			   #{item}
			</foreach>)
			</script>
	"""})
	List<String> likedTop5(@Param("ids") List ids);
}




